package com.panels;

import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;

import com.main.TrainFrame;

public class ManageTrainPanel extends JDialog implements ActionListener{
	
	TrainFrame trainFrame;
	private JPanel center;
	private JButton save_train;
	private JButton load_train;
	private JButton build_train;
	

	public ManageTrainPanel(TrainFrame trainFrame) {
		
		this.trainFrame=trainFrame;
		
		setSize(300,200);
		center=new JPanel(null);
		setModal(true);
		
		int r=10;	
		
		
		build_train=new JButton("Built/edit train");
		build_train.addActionListener(this);
		build_train.setBounds(10,r,120,20);
		center.add(build_train);
		
		r+=30;
		
		save_train=new JButton("Save train");
		save_train.addActionListener(this);
		save_train.setBounds(10,r,120,20);
		center.add(save_train);
		
		
		load_train=new JButton("Load train");
		load_train.addActionListener(this);
		load_train.setBounds(130,r,120,20);
		center.add(load_train);
		
		add(BorderLayout.CENTER,center);
		setVisible(true);
		
	}
	
	
	@Override
	public void actionPerformed(ActionEvent arg0) {
		
		Object obj = arg0.getSource();
		
		if(obj==save_train){			
			
			dispose();
			trainFrame.saveTrain();
			
		}
		else if(obj==load_train){
			
			dispose();
			trainFrame.loadTrain();
			
			
		}
		else if(obj==build_train){
			
			dispose();
			trainFrame.buildEditTrain();
			
		}
		

	}

}
